package com.chanta.server.persistence;

import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * TODO Please comment this class..
 * 
 * @author Hakan Özdemir - Vendoo Inc.
 * @date 01.11.2013
 * 
 */
@PersistenceCapable
public class User {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent(defaultFetchGroup = "true", mappedBy = "user")
	private List<UserImage> userImages;

	@Persistent(mappedBy = "owner")
	private List<Portal> portals;

	@Persistent(mappedBy = "owner")
	private List<Message> messages;

	@Persistent(mappedBy = "owner")
	private List<Feedback> feedbacks;

	@Persistent
	private List<Rule> rules;

	@Persistent
	private Seenlist seenlist;

	@Persistent
	private Wishlist wishlist;

	@Persistent
	private String email;

	@Persistent
	private String password;

	@Persistent
	private String givenname;

	@Persistent
	private String familyname;

	@Persistent
	private String state;

	@Persistent
	private Boolean administrator;

	@Persistent
	private Date registrationDate;

	@Persistent
	private String registrationIP;

	@Persistent
	private String lastloginIP;

	@Persistent
	private Date lastloginDate;

	@Persistent
	private int failedLoginCount = 0;

	@Persistent
	private Boolean passwordToChange = Boolean.TRUE;

	/**
	 * The constructor.
	 * 
	 * @param email
	 * @param password
	 */
	public User(final String email, final String password) {
		this.email = email;
		this.password = password;
		this.setRegistrationDate(new Date(System.currentTimeMillis()));
	}

	/**
	 * Getter for userImages.
	 * 
	 * @return userImages
	 */
	public List<UserImage> getUserImages() {
		return userImages;
	}

	/**
	 * Setter for userImages.
	 * 
	 * @param userImages
	 *            the userImages to set
	 */
	public void setUserImages(List<UserImage> userImages) {
		this.userImages = userImages;
	}

	/**
	 * Getter for portals.
	 * 
	 * @return portals
	 */
	public List<Portal> getPortals() {
		return portals;
	}

	/**
	 * Setter for portals.
	 * 
	 * @param portals
	 *            the portals to set
	 */
	public void setPortals(List<Portal> portals) {
		this.portals = portals;
	}

	/**
	 * Getter for messages.
	 * 
	 * @return messages
	 */
	public List<Message> getMessages() {
		return messages;
	}

	/**
	 * Setter for messages.
	 * 
	 * @param messages
	 *            the messages to set
	 */
	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}

	/**
	 * Getter for feedbacks.
	 * 
	 * @return feedbacks
	 */
	public List<Feedback> getFeedbacks() {
		return feedbacks;
	}

	/**
	 * Setter for feedbacks.
	 * 
	 * @param feedbacks
	 *            the feedbacks to set
	 */
	public void setFeedbacks(List<Feedback> feedbacks) {
		this.feedbacks = feedbacks;
	}

	/**
	 * Getter for rules.
	 * 
	 * @return rules
	 */
	public List<Rule> getRules() {
		return rules;
	}

	/**
	 * Setter for rules.
	 * 
	 * @param rules
	 *            the rules to set
	 */
	public void setRules(List<Rule> rules) {
		this.rules = rules;
	}

	/**
	 * Getter for seenlist.
	 * 
	 * @return seenlist
	 */
	public Seenlist getSeenlist() {
		return seenlist;
	}

	/**
	 * Setter for seenlist.
	 * 
	 * @param seenlist
	 *            the seenlist to set
	 */
	public void setSeenlist(Seenlist seenlist) {
		this.seenlist = seenlist;
	}

	/**
	 * Getter for wishlist.
	 * 
	 * @return wishlist
	 */
	public Wishlist getWishlist() {
		return wishlist;
	}

	/**
	 * Setter for wishlist.
	 * 
	 * @param wishlist
	 *            the wishlist to set
	 */
	public void setWishlist(Wishlist wishlist) {
		this.wishlist = wishlist;
	}

	/**
	 * Getter for email.
	 * 
	 * @return email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Setter for email.
	 * 
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Getter for password.
	 * 
	 * @return password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Setter for password.
	 * 
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Getter for givenname.
	 * 
	 * @return givenname
	 */
	public String getGivenname() {
		return givenname;
	}

	/**
	 * Setter for givenname.
	 * 
	 * @param givenname
	 *            the givenname to set
	 */
	public void setGivenname(String givenname) {
		this.givenname = givenname;
	}

	/**
	 * Getter for familyname.
	 * 
	 * @return familyname
	 */
	public String getFamilyname() {
		return familyname;
	}

	/**
	 * Setter for familyname.
	 * 
	 * @param familyname
	 *            the familyname to set
	 */
	public void setFamilyname(String familyname) {
		this.familyname = familyname;
	}

	/**
	 * Getter for state.
	 * 
	 * @return state
	 */
	public String getState() {
		return state;
	}

	/**
	 * Setter for state.
	 * 
	 * @param state
	 *            the state to set
	 */
	public void setState(String state) {
		this.state = state;
	}

	/**
	 * Getter for administrator.
	 * 
	 * @return administrator
	 */
	public Boolean getAdministrator() {
		return administrator;
	}

	/**
	 * Setter for administrator.
	 * 
	 * @param administrator
	 *            the administrator to set
	 */
	public void setAdministrator(Boolean administrator) {
		this.administrator = administrator;
	}

	/**
	 * Getter for registrationDate.
	 * 
	 * @return registrationDate
	 */
	public Date getRegistrationDate() {
		return registrationDate;
	}

	/**
	 * Setter for registrationDate.
	 * 
	 * @param registrationDate
	 *            the registrationDate to set
	 */
	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = registrationDate;
	}

	/**
	 * Getter for registrationIP.
	 * 
	 * @return registrationIP
	 */
	public String getRegistrationIP() {
		return registrationIP;
	}

	/**
	 * Setter for registrationIP.
	 * 
	 * @param registrationIP
	 *            the registrationIP to set
	 */
	public void setRegistrationIP(String registrationIP) {
		this.registrationIP = registrationIP;
	}

	/**
	 * Getter for lastloginIP.
	 * 
	 * @return lastloginIP
	 */
	public String getLastloginIP() {
		return lastloginIP;
	}

	/**
	 * Setter for lastloginIP.
	 * 
	 * @param lastloginIP
	 *            the lastloginIP to set
	 */
	public void setLastloginIP(String lastloginIP) {
		this.lastloginIP = lastloginIP;
	}

	/**
	 * Getter for lastloginDate.
	 * 
	 * @return lastloginDate
	 */
	public Date getLastloginDate() {
		return lastloginDate;
	}

	/**
	 * Setter for lastloginDate.
	 * 
	 * @param lastloginDate
	 *            the lastloginDate to set
	 */
	public void setLastloginDate(Date lastloginDate) {
		this.lastloginDate = lastloginDate;
	}

	/**
	 * Getter for failedLoginCount.
	 * 
	 * @return failedLoginCount
	 */
	public int getFailedLoginCount() {
		return failedLoginCount;
	}

	/**
	 * Setter for failedLoginCount.
	 * 
	 * @param failedLoginCount
	 *            the failedLoginCount to set
	 */
	public void setFailedLoginCount(int failedLoginCount) {
		this.failedLoginCount = failedLoginCount;
	}

	/**
	 * Getter for passwordToChange.
	 * 
	 * @return passwordToChange
	 */
	public Boolean getPasswordToChange() {
		return passwordToChange;
	}

	/**
	 * Setter for passwordToChange.
	 * 
	 * @param passwordToChange
	 *            the passwordToChange to set
	 */
	public void setPasswordToChange(Boolean passwordToChange) {
		this.passwordToChange = passwordToChange;
	}
}
